package com.eos.control.action.activity;

import com.eos.business.service.SysActivityBusinessService;
import com.eos.common.tool.ObjectUtils;
import com.eos.control.action.base.AbstractBaseAction;
import com.eos.orm.mybatis.model.SalesModel;
import com.eos.orm.mybatis.model.SysUser;

public class UpdateBuyMethodAction extends AbstractBaseAction {
	private static final long serialVersionUID = 1926243812057698423L;
	private Integer buyMethodId;
	private String salesName;

	public void setBuyMethodId(Integer buyMethodId) {
		this.buyMethodId = buyMethodId;
	}

	public void setSalesName(String salesName) {
		this.salesName = salesName;
	}

	@Override
	public String execute() {
		try {
			if (null == buyMethodId || buyMethodId.intValue() <= 0) {
				statusCode = "300";
				message = "参数错误, 修改失败!";
			} else {
				SysUser user = (SysUser) getSession().getAttribute("SysUser");
				String userId = user.getId()+"";
				SalesModel saleModel = new SalesModel();
				saleModel.setId(buyMethodId);
				saleModel.setSalesName(salesName);
				saleModel.setUpdateUserId(userId);
				saleModel.setModifyTime(ObjectUtils.formatDate(null, "yyyy-MM-dd HH:mm:ss"));
				SysActivityBusinessService sabs = new SysActivityBusinessService();
				String exeStatus = sabs.updateSaleModelPKSelective(saleModel);
				if("SUCCESS".equals(exeStatus)){
					statusCode = "200";
					message = "修改销售方式信息成功!";
				}else{
					statusCode = "300";
					message = "系统繁忙, 修改销售方式信息失败!";
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			statusCode = "300";
			message = "系统异常, 修改销售方式信息失败!";
		}
		return SUCCESS;
	}
}
